package cn.iocoder.yudao.module.erp.controller.admin.purchaseorder.vo;

import cn.iocoder.yudao.module.erp.dal.dataobject.purchaseorder.PurchaseOrderGoodsDO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

@Schema(description = "管理后台 - 采购订单新增/修改 Request VO")
@Data
public class PurchaseOrderSaveReqVO {

    @Schema(description = "id单号")
    private Long id;

    @Schema(description = "销售订单id", requiredMode = Schema.RequiredMode.REQUIRED, example = "9843")
    @NotNull(message = "销售订单id不能为空")
    private Long saleId;

    @Schema(description = "上游单据（销售订单）", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotEmpty(message = "上游单据（销售订单）不能为空")
    private String saleNo;

    @Schema(description = "采购单号", requiredMode = Schema.RequiredMode.REQUIRED)
    private String billNo;

    @Schema(description = "采购日期", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "采购日期不能为空")
    private LocalDateTime billDate;

    @Schema(description = "采购方")
    private String billContacter;

    @Schema(description = "采购联系人", example = "芋艿")
    private String billContacterName;

    @Schema(description = "采购电话")
    private String billContacterMobile;

    @Schema(description = "仓库id", example = "20405")
    private Integer warehouseId;

    @Schema(description = "仓库名称", example = "王五")
    private String warehouseName;

    @Schema(description = "订单号")
    private String supplierOrderNo;

    @Schema(description = "供应商id", example = "974")
    private Long supplierId;

    @Schema(description = "供应商名称（公司）", example = "张三")
    private String supplierName;

    @Schema(description = "供应商联系人", example = "王五")
    private String supplierContacterName;

    @Schema(description = "供应商联系电话")
    private String supplierMobile;

    @Schema(description = "总数量")
    private BigDecimal aggregateQuantity;

    @Schema(description = "总金额")
    private BigDecimal aggregateAmount;

    @Schema(description = "优惠金额")
    private BigDecimal discountAmount;

    @Schema(description = "优惠后总金额")
    private BigDecimal totalAmount;

    @Schema(description = "交付地址")
    private String deliveryAddress;

    @Schema(description = "物品信息（名称+数量）")
    private String goodsInfo;

    @Schema(description = "项目id", example = "14415")
    private Integer projectId;

    @Schema(description = "项目名称", example = "王五")
    private String projectName;

    @Schema(description = "结算方式id", example = "21666")
    private Integer settlementId;

    @Schema(description = "结算方式", example = "芋艿")
    private String settlementName;

    @Schema(description = "备注")
    private String remarks;

    @Schema(description = "附件")
    private String file;

    @Schema(description = "是否付款", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "是否付款不能为空")
    private Boolean syncPay;

    @Schema(description = "是否入库", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "是否入库不能为空")
    private Boolean syncIn;

    @Schema(description = "是否开票", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "是否开票不能为空")
    private Boolean syncInvoice;

//    @Schema(description = "采购单和物品的链接表-多对多关系列表")
//    private List<Item> items;

    @Schema(description = "采购单和物品的链接表-多对多关系列表")
    private List<PurchaseOrderGoodsDO> purchaseOrderGoodss;

    @Data
    public static class Item {
        @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "8938")
        private Long id;

        @Schema(description = "订单id", requiredMode = Schema.RequiredMode.REQUIRED, example = "14935")
        @NotNull(message = "订单id不能为空")
        private Long orderId;

        @Schema(description = "物品id", requiredMode = Schema.RequiredMode.REQUIRED, example = "27315")
        @NotNull(message = "物品id不能为空")
        private Long goodsId;

        @Schema(description = "物品编号", requiredMode = Schema.RequiredMode.REQUIRED)
        @NotEmpty(message = "物品编号不能为空")
        private String code;

        @Schema(description = "物品规格型号")
        private String models;

        @Schema(description = "英文名称")
        private String nameEn;

        @Schema(description = "交付日期")
        private LocalDateTime deliveryData;

        @Schema(description = "备注")
        private String remarks;

        @Schema(description = "物品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
        @NotEmpty(message = "物品名称不能为空")
        private String name;

        @Schema(description = "仓库id", example = "24017")
        private Long warehouseId;

        @Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED)
        @NotNull(message = "数量不能为空")
        private BigDecimal number;

        @Schema(description = "税率")
        private BigDecimal taxRate;

        @Schema(description = "未税单价", example = "28711")
        private BigDecimal noTaxPrice;

        @Schema(description = "未税总额")
        private BigDecimal noTaxTotal;

        @Schema(description = "税额")
        private BigDecimal tax;

        @Schema(description = "单价", example = "19686")
        private BigDecimal price;

        @Schema(description = "价税总额")
        private BigDecimal total;

        @Schema(description = "单位成本")
        private BigDecimal unitCost;

        @Schema(description = "采购退货数量")
        private BigDecimal outNum;

        @Schema(description = "入库数量", requiredMode = Schema.RequiredMode.REQUIRED)
        @NotNull(message = "入库数量不能为空")
        private BigDecimal inNum;

        @Schema(description = "未入库数量")
        private BigDecimal noInNum;
    }

}